﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Microfinance_Management
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
      
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
      //      Login lg = new Login();
         //   Application.Run();

       //     Main mn = new Main();
         //   mn.ShowDialog();
            string ID = "";
            Login lg = new Login();
            DialogResult curResult = DialogResult.OK;

        MAIN:
            while ((curResult = lg.ShowDialog()) == DialogResult.None)
            {
                ;
            }
            if (curResult == DialogResult.OK)
            {
                int access_type = lg.Accesstype;
                ID = lg.ID;
                if (access_type == 0)
                {
                    Operator op = new Operator(ID);
                    if (op.ShowDialog() == DialogResult.OK)
                    {
                        goto MAIN;
                    }
                    MySQL.DisConnectSQL();
                }
                else if (access_type == 1)
                {
                    Approval ap = new Approval(ID, access_type);

                    //Application.Run(ap);
                    if (ap.ShowDialog() == DialogResult.OK)
                    {
                        goto MAIN;
                    }
                    MySQL.DisConnectSQL();
                }
                else if (access_type == 3)
                {
                    Investigator inv = new Investigator(ID);
                    // Application.Run(inv);
                    if (inv.ShowDialog() == DialogResult.OK)
                    {
                        goto MAIN;
                    }
                    MySQL.DisConnectSQL();
                } 
                else if (access_type == 2)
                {
                    Approval ap = new Approval(ID, access_type);
                    //Application.Run(ap);
                    if (ap.ShowDialog() == DialogResult.OK)
                    {
                        goto MAIN;
                    }
                    MySQL.DisConnectSQL();
                }
                else if (access_type == 4)
                {
                    Administractor ad = new Administractor();

                    //Application.Run(ad);
                    if (ad.ShowDialog() == DialogResult.OK)
                    {
                        goto MAIN;
                    }
                    MySQL.DisConnectSQL();
                }

            }


        }
    }
}